package model

import (
	"fmt"
	"time"
)

type Customer struct {
	CustomerId int64 `xorm:"pk autoincr"`
	CustomerName string
	FounderId int64
	FounderName string
	BelongerId int64
	BelongerName string
	AllocationTime time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
 }

func (ct *Customer)InsertCustomer(c *Customer) map[string]interface{}{
	x.Insert(c)
	return map[string]interface{}{"message": "成功","code":"200"}
}

func (ct *Customer)QueryCustomerById(cId int64) Customer{
	var c Customer
	x.Id(cId).Get(&c)
	return c
}

func (ct *Customer)QueryCustomerByBloo(cId int64) bool{
	c := new(Customer)
	x.Id(cId).Get(c)
	if c.CustomerId != 0 && time.Now().Sub(c.AllocationTime).Hours()/24 <= 90{
		fmt.Println(time.Now().Sub(c.AllocationTime).Hours()/24)
		return true
	}
	return false
}